Return * for n number of times


Posted by Christy on 2022-04-19

Description: Write a function that accepts a number n and returns * for n number of times

function star(n) {

}

console.log(star(3)); // ***
function star(n) {
  let result = "";
  for (let i = 1; i <= n; i++) {
    result += "*";
  }
  return result;
}

console.log(star(3));

Be careful about the way of ouput, if it's print -> console.log; if it's return -> return










Related Posts

DAY23:Build a pile of Cubes

DAY23:Build a pile of Cubes

如何 embed binary 到 shell script 中並執行取得結果

如何 embed binary 到 shell script 中並執行取得結果

不用dynamic dns,使用ssh連上非固定IP的linux電腦

不用dynamic dns,使用ssh連上非固定IP的linux電腦


Comments